<?php
namespace app\admin\controller;
use app\admin\code\BaseCode;
use app\admin\logic\ContentLogic;
use app\admin\model\ContentModel;
use app\admin\util\Page;
use app\admin\util\Response;
use app\admin\validate\ContentValidate;
use think\Request;

class Content extends Base
{
    public function index(){
        if($this->request->isAjax()){
            $model = new ContentModel();
            $list = $model->selectData([]);
            $size = input('limit',10,'intval');
            $page = input('page',1,'intval');
            Response::json(BaseCode::SUCCESS,'',Page::return_page_data($list,$size,$page));
        }else{
            return view();
        }
    }
    public function del(){
        $param = [];
        $param['id'] = input('id',0,'intval');
        $logic = new ContentLogic($param);
        if($logic->del(new ContentValidate(new ContentModel()))){
            Response::json(BaseCode::SUCCESS);
        }else{
            Response::json($logic->err['code'],$logic->err['msg']);
        }
    }
    public function detail(){
        $id = input('id',0,'intval');
        $model = new ContentModel();
        $vo = $model->findData(['id'=>$id]);
        $this->assign('vo',$vo);
        $this->assign('is_update',1);
        return view('oppt');
    }

}